import java.util.Calendar;
import java.util.GregorianCalendar;

import models.*;

import org.junit.Test;

import play.test.UnitTest;


public class createAndEditSprint extends UnitTest
{
	@Test
	public void createSprintTest()
	{
		Project testProject = new Project("test project",10,false,"just a test ").save();
		Event testSprint = new Event("Test Sprint", "A test Sprint", null,
				new GregorianCalendar(14,6,2010), new GregorianCalendar(25,6,2010));
		testSprint.type = EventType.find("byType", "Sprint").first();
		testSprint.project = testProject;
		testSprint.save();
		Event storedSprint = Event.find("byName", "Test Sprint").first();
		assertNotNull(storedSprint);
		System.out.println(storedSprint.startDate.toString());
		assertTrue(new GregorianCalendar(25,6,2010).equals(storedSprint.endDate));
	}
	
	@Test
	public void editSprintInfoTest()
	{
		Project testProject = new Project("test project",10,false,"just a test ").save();
		Event testSprint = new Event("Another Test Sprint", "A test Sprint", null,
				new GregorianCalendar(14,6,2010), new GregorianCalendar(25,6,2010));
		testSprint.type = EventType.find("byType", "Sprint").first();
		testSprint.project = testProject;
		testSprint.save();
		Event storedSprint = Event.find("byName", "Another Test Sprint").first();
		storedSprint.setStartDate(new GregorianCalendar(20,6,2010));
		storedSprint.save();
		assertNotNull(storedSprint);
		assertTrue(new GregorianCalendar(20,6,2010).equals(storedSprint.startDate));
	}
}
